from utils import Singleton
import  requests
from paddleocr import PaddleOCR
class PaddOrcModel(metaclass=Singleton):
    def __init__(self) -> None:
        self.ocr = PaddleOCR(lang='ch',use_gpu=True,gpu_id=0)
    
    def orcImg(self,img_path,min=0.8):
        response = requests.get(img_path)
        img_path = response.content
        result = self.ocr.ocr(img_path)
        out = ''
        for line in result:
        # print(line)
            for item in line:
                if item[-1:][0][1]>min:
                    out+=item[-1:][0][0]
            return out